<template>
	<div>
    <span v-if="!isGod">
      <el-button :disabled="!rfVisible" type="success" class="pan-btn success-btn" v-print="'#report'" size="mini">打印</el-button>
      {{ '共' + page + '页' }}
      <el-button v-if="checkList.checkTypeId == 4" type="success" class="pan-btn success-btn" @click="toDingTalk" :loading="uploading" size="mini">发送到钉钉群</el-button>
    </span>
    <el-button type="danger" class="pan-btn danger-btn" @click="godMode" size="mini" v-if="isAuth('statistics:printreport:god') && !isGod">修改模式</el-button>
    <el-button type="danger" class="pan-btn danger-btn" @click="godModeExit" size="mini" v-if="isGod">退出修改模式</el-button>
    <div id="report">
      <div v-for="(report, rIndex) in tableList" :id="reportId(rIndex)" :key="rIndex">
        <div style="height: 20px;"></div>
        <div id="report-container" class="report-container">
          <div class="report-head">
            <img src="../../../../assets/img/logoNew.png" style="height: 55px;" />
            <b>{{ reportInfo.companyName }}</b>
            <span style="margin-left: 330px" v-if="reportInfo.reportNum != null">文件编号：{{ reportInfo.reportNum }}</span>
          </div>
          <div class="name-box">
            <div class="report-name">
              <b>{{ reportInfo.reportName }}</b>
            </div>
          </div>
          <div class="table-box">
            <div>
              <table border="1" v-if="yfb && !qt">
                <tr>
                	<td class="info-lable">检品名称</td>
                	<td class="info-value-container">
                    <el-input v-if="productNameInput" v-model="checkList.productName" @blur="setListContent('product_name', checkList.productName)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('product_name')" v-html="checkList.productName"></div>
                  </td>
                	<td class="info-lable">报告编号</td>
                	<td class="info-value-container">
                    <el-input v-if="checkNumInput" v-model="checkList.checkNum" @blur="setListContent('check_num', checkList.checkNum)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('check_num')" v-html="checkList.checkNum"></div>
                  </td>
                </tr>
                <tr>
                  <td class="info-lable">物料编码</td>
                  <td class="info-value-container">
                    <el-input v-if="productGmpInput" v-model="checkList.productGmp" @blur="setListContent('product_gmp', checkList.productGmp)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('product_gmp')" v-html="checkList.productGmp"></div>
                  </td>
                	<td class="info-lable">入厂批号</td>
                	<td class="info-value-container">
                    <el-input v-if="batchNumInput" v-model="checkList.batchNum" @blur="setListContent('batch_num', checkList.batchNum)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('batch_num')" v-html="checkList.batchNum + (yfbList.checkPurposeName == '复验' ? ' (复验)' : '')"></div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">请验部门</td>
                	<td class="info-value-container">
                    <el-input v-if="registCheckDepartmentNameInput" v-model="checkList.registCheckDepartmentName" @blur="setListContent('regist_check_department_name', checkList.registCheckDepartmentName)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('regist_check_department_name')" v-html="checkList.registCheckDepartmentName"></div>
                  </td>
                	<td class="info-lable">原厂批号</td>
                	<td class="info-value-container">
                    <el-input v-if="originalBatchInput" v-model="yfbList.originalBatch" @blur="setYfbContent('original_batch', yfbList.originalBatch)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('original_batch')" v-html="yfbList.originalBatch"></div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">包装规格</td>
                	<td class="info-value-container">
                    <el-input v-if="productPackSpecInput" v-model="checkList.productPackSpec" @blur="setListContent('product_pack_spec', checkList.productPackSpec)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('product_pack_spec')" v-html="checkList.productPackSpec == null || checkList.productPackSpec == '' ? '无' : checkList.productPackSpec"></div>
                  </td>
                	<td class="info-lable">数&nbsp;&nbsp;量</td>
                	<td class="info-value-container">
                    <el-input v-if="grossQuantityInput" v-model="yfbList.grossQuantity" @blur="setYfbContent('gross_quantity', yfbList.grossQuantity, 'grossQuantityInput')" size="small" style="width: 65%;" />
                    <el-input v-if="grossQuantityInput" v-model="yfbList.grossUnitName" @blur="setYfbContent('gross_unit_name', yfbList.grossUnitName, 'grossQuantityInput')" size="small" style="width: 30%;" />
                    <div v-else @click="number2Filter('yfbList','grossQuantity','gross_quantity')" class="info-value point gold-model" v-html="yfbList.grossQuantity + yfbList.grossUnitName"></div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">供货单位</td>
                	<td class="info-value-container">
                    <el-input v-if="supplierNameInput" v-model="yfbList.supplierName" @blur="setYfbContent('supplier_name', yfbList.supplierName)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('supplier_name')" v-html="yfbList.supplierName"></div>
                  </td>
                	<td class="info-lable">生产单位</td>
                	<td class="info-value-container">
                    <el-input v-if="manufacturerNameInput" v-model="yfbList.manufacturerName" @blur="setYfbContent('manufacturer_name', yfbList.manufacturerName)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('manufacturer_name')">{{yfbList.manufacturerName}}</div>
                  </td>
                </tr>
                <tr>
                	<td v-if="yfbList.reinspectDate != null" class="info-lable">复 验 期</td>
                	<td v-if="yfbList.reinspectDate != null" class="info-value-container">
                    <template v-if="reinspectDateInput">
                      <el-date-picker
                        v-model="yfbList.reinspectDate"
                        @blur="setYfbContent('reinspect_date', yfbList.reinspectDate)"
                        align="right"
                        :type="dateTypeFilter(yfbList.selectDateUnit)"
                        style="width: 80%"
                        :format="dateFormatFilter(yfbList.selectDateUnit)"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        size="small">
                      </el-date-picker>
                      <el-tooltip :content="yfbList.selectDateUnit == 0 ? '此时精确到日' : '此时精确到月'" placement="top">
                        <el-switch
                          v-model="yfbList.selectDateUnit"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          @click.native="setYfbContent('select_date_unit', yfbList.selectDateUnit, 'reinspectDateInput')"
                          :active-value="1"
                          :inactive-value="0"
                          size="mini">
                        </el-switch>
                      </el-tooltip>
                    </template>
                    <div v-else @click="openSet('reinspect_date')" class="info-value gold-model">{{ yfbList.reinspectDate | showTime(yfbList.selectDateUnit) }}</div>
                  </td>
                  <td v-if="yfbList.reinspectDate == null" class="info-lable">有效期至</td>
                  <td v-if="yfbList.reinspectDate == null" class="info-value-container">
                    <template v-if="validityDateInput">
                      <el-date-picker
                        v-model="yfbList.validityDate"
                        @blur="setYfbContent('validity_date', yfbList.validityDate)"
                        align="right"
                        :type="dateTypeFilter(yfbList.selectDateUnit)"
                        style="width: 80%"
                        :format="dateFormatFilter(yfbList.selectDateUnit)"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        size="small">
                      </el-date-picker>
                      <el-tooltip :content="yfbList.selectDateUnit == 0 ? '此时精确到日' : '此时精确到月'" placement="top">
                        <el-switch
                          v-model="yfbList.selectDateUnit"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          @click.native="setYfbContent('select_date_unit', yfbList.selectDateUnit, 'validityDateInput')"
                          :active-value="1"
                          :inactive-value="0"
                          size="mini">
                        </el-switch>
                      </el-tooltip>
                    </template>
                    <div v-else @click="openSet('validity_date')" class="info-value gold-model">{{ yfbList.validityDate | showTime(yfbList.selectDateUnit) }}</div>
                  </td>
                	<td class="info-lable">请检日期</td>
                	<td class="info-value-container">
                    <el-date-picker
                      v-if="registCheckDateInput"
                      v-model="checkList.registCheckDate"
                      @blur="setListContent('regist_check_date', checkList.registCheckDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('regist_check_date')" class="info-value gold-model">{{ checkList.registCheckDate | showTime }}</div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">检验日期</td>
                	<td class="info-value-container">
                    <el-date-picker
                      v-if="inspectDateInput"
                      v-model="checkList.inspectDate"
                      @blur="setListContent('inspect_date', checkList.inspectDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('inspect_date')" class="info-value gold-model">{{ checkList.inspectDate | showTime }}</div>
                  </td>
                	<td class="info-lable">报告日期</td>
                	<td class="info-value-container">
                    <el-date-picker
                      v-if="reportDateInput"
                      v-model="checkList.reportDate"
                      @blur="setListContent('report_date', checkList.reportDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('report_date')" class="info-value gold-model">{{ checkList.reportDate | showTime }}</div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">检验依据</td>
                	<td class="info-value-container" colspan="3"><div class="info-value" v-html="standard.accordingToInside"></div></td>
                </tr>
              </table>
              <table border="1" v-if="qt || wk">
                <tr>
                	<td class="info-lable">检品名称</td>
                	<td class="info-value-container">
                    <div v-if="qt" class="info-value" v-html="checkList.productName"></div>
                    <div v-else class="info-value" v-html="checkList.productName + '(' + wkList.stabilityModeName + wkList.timeValue + wkList.timeName + ')'"></div>
                  </td>
                  <td class="info-lable">报告编号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.checkNum"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">请验部门</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.registCheckDepartmentName"></div></td>
                	<td class="info-lable">批&nbsp;&nbsp;号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.batchNum"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">规&nbsp;&nbsp;格</td>
                	<td class="info-value-container">
                    <div v-if="qt" class="info-value" v-html="checkList.productPackSpec"></div>
                    <div v-else class="info-value" v-html="checkList.productSpec"></div>
                  </td>
                	<td class="info-lable">来&nbsp;&nbsp;源</td>
                	<td class="info-value-container">
                    <div v-if="qt" class="info-value" v-html="yfbList.manufacturerName"></div>
                    <div v-else class="info-value">{{ '稳定性考察室' }}</div>
                  </td>
                </tr>
                <tr>
                	<td class="info-lable">数&nbsp;&nbsp;量</td>
                	<td class="info-value-container">
                    <div v-if="qt" class="info-value" @click="number2Filter('yfbList','grossQuantity')" v-html="yfbList.grossQuantity + yfbList.grossUnitName"></div>
                    <div v-else class="info-value" v-html="Math.round(checkList.getQuantity) + checkList.getUnitName"></div>
                  </td>
                	<td class="info-lable">请检日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.registCheckDate | showTime }}</div></td>
                </tr>
                <tr>
                	<td class="info-lable">检验日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.inspectDate | showTime }}</div></td>
                	<td class="info-lable">报告日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.reportDate | showTime }}</div></td>
                </tr>
                <tr>
                	<td class="info-lable">检验依据</td>
                	<td class="info-value-container" colspan="3">
                    <div v-if="qt" class="info-value" v-html="standard.accordingToInside"></div>
                    <!-- <div v-else class="info-value" v-html="standard.accordingToInside"></div>   jcf  71 gai -->
                    <div v-else class="info-value" v-html="standard.accordingToNation"></div>
                  </td>
                </tr>
              </table>
              <table border="1" v-if="zc">
                <tr>
                	<td class="info-lable">检品名称</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.productName.replace(/\([n=2)]*\)/,'').replace(/\([n=1.8)]*\)/,'')"></div></td>
                	<td class="info-lable">报告编号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.checkNum"></div></td>
                </tr>
                <tr v-if="zp">
                	<td class="info-lable">生产车间</td>
                	<td class="info-value-container"><div class="info-value" v-html="zcList.workshopName"></div></td>
                	<td class="info-lable">生产工序</td>
                	<td class="info-value-container"><div class="info-value" v-html="zcList.procedureName"></div></td>
                </tr>
                <tr v-if="cp">
                	<td class="info-lable">请验部门</td>
                	<td class="info-value-container"><div class="info-value" v-html="zcList.workshopName"></div></td>
                	<td class="info-lable">产品编码</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.productGmp"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">批&nbsp;&nbsp;号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.batchNum"></div></td>
                	<td class="info-lable">规&nbsp;&nbsp;格</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.productSpec"></div></td>
                </tr>
                <tr v-if="zp">
                	<td class="info-lable">取样数量</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.getQuantity + checkList.getUnitName"></div></td>
                	<td class="info-lable">数&nbsp;&nbsp;量</td>
                	<td class="info-value-container"><div class="info-value" v-html="zcList.batchQuantity + zcList.batchUnitName"></div></td>
                </tr>
                <tr v-if="zp">
                	<td class="info-lable">请验日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.registCheckDate | showTime }}</div></td>
                	<td class="info-lable">检验日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.inspectDate | showTime }}</div></td>
                </tr>
                <tr v-if="cp">
                	<td class="info-lable">包装规格</td>
                	<td class="info-value-container">
                    <el-input v-if="productPackSpecInput" v-model="checkList.productPackSpec" @blur="setListContent('product_pack_spec', checkList.productPackSpec)" size="small" style="width: 100%;" />
                    <div class="info-value gold-model" v-else @click="openSet('product_pack_spec')" v-html="checkList.productPackSpec == null || checkList.productPackSpec == '' ? '无' : checkList.productPackSpec"></div>
                  </td>
                	<td class="info-lable">产成品量</td>
                	<td class="info-value-container">
                    <el-input v-if="productionQuantityInput" v-model="zcList.productionQuantity" @blur="setZcContent('production_quantity', zcList.productionQuantity, 'productionQuantityInput')" size="small" style="width: 65%;" />
                    <el-input v-if="productionQuantityInput" v-model="zcList.productionUnitName" @blur="setZcContent('production_unit_name', zcList.productionUnitName, 'productionQuantityInput')" size="small" style="width: 30%;" />
                    <div v-else class="info-value point gold-model" @click="number2Filter('zcList','productionQuantity','production_quantity')" v-html="zcList.productionQuantity + zcList.productionUnitName"></div>
                  </td>
                </tr>
                <tr v-if="cp">
                	<td class="info-lable">生产日期</td>
                  <td class="info-value-container">
                    <el-date-picker
                      v-if="productionDateInput"
                      v-model="zcList.productionDate"
                      @blur="setZcContent('production_date', zcList.productionDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('production_date')" class="info-value gold-model">{{ zcList.productionDate | showTime }}</div>
                  </td>
                	<td class="info-lable">有效期至</td>
                  <td class="info-value-container">
                    <el-date-picker
                      v-if="validityDateInput"
                      v-model="zcList.validityDate"
                      @blur="setZcContent('validity_date', zcList.validityDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('validity_date')" class="info-value gold-model">{{ zcList.validityDate | showTime }}</div>
                  </td>
                </tr>
                <tr v-if="cp">
                	<td class="info-lable">检验日期</td>
                	<!-- <td class="info-value-container"><div class="info-value">{{ checkList.inspectDate | showTime }}</div></td> -->
                  <td class="info-value-container">
                    <el-date-picker
                      v-if="inspectDateInput"
                      v-model="checkList.inspectDate"
                      @blur="setListContent('inspect_date', checkList.inspectDate)"
                      align="right"
                      type="date"
                      style="width: 100%;"
                      format="yyyy年MM月dd日"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="small">
                    </el-date-picker>
                    <div v-else @click="openSet('inspect_date')" class="info-value gold-model">{{ checkList.inspectDate | showTime }}</div>
                  </td>
                	<td class="info-lable">报告日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.reportDate | showTime }}</div></td>
                </tr>
                <tr v-if="zp">
                	<td class="info-lable">报告日期</td>
                	<td class="info-value-container" colspan="3"><div class="info-value">{{ checkList.reportDate | showTime }}</div></td>
                </tr>
                <tr>
                	<td class="info-lable">检验依据</td>
                	<td class="info-value-container" colspan="3"><div class="info-value" v-html="cp ? standard.accordingToNation : standard.accordingToInside"></div></td>
                </tr>
              </table>
              <table border="1" v-if="ys">
                <tr>
                	<td class="info-lable">检品名称</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.productName"></div></td>
                	<td class="info-lable">报告编号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.checkNum"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">物料编码</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.productGmp"></div></td>
                	<td class="info-lable">取样位置</td>
                	<td class="info-value-container"><div class="info-value" v-html="ysList.workshopName"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">取 样 点</td>
                	<td class="info-value-container" colspan="3"><div class="info-value" v-html="ysList.getNames"></div></td>
                </tr>
                <tr>
                	<td class="info-lable">批&nbsp;&nbsp;号</td>
                	<td class="info-value-container"><div class="info-value" v-html="checkList.batchNum"></div></td>
                	<td class="info-lable">请验日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.registCheckDate | showTime }}</div></td>
                </tr>
                <tr>
                	<td class="info-lable">检验日期</td>
                	<td class="info-value-container"><div class="info-value">{{ checkList.inspectDate | showTime }}</div></td>
                  <td class="info-lable">报告日期</td>
                  <td class="info-value-container"><div class="info-value">{{ checkList.reportDate | showTime }}</div></td>
                </tr>
                <tr>
                	<td class="info-lable">检验依据</td>
                	<td class="info-value-container" colspan="3"><div class="info-value" v-html="standard.accordingToInside"></div></td>
                </tr>
              </table>
            </div>
            <div v-if="report.showPageUp" class="text-center page-up">(接上一页)</div>
            <div class="report-table-container">
              <table :id="tableId(rIndex)">
                <tr>
                  <td class="jyxm"><b>检验项目</b></td>
                  <td class="jyxm_b"></td>
                  <td class="bzgd"><b>标准规定</b></td>
                  <td class="bzgd_b"></td>
                  <td class="jyjg"><b>检验结果</b></td>
                </tr>
                <tr v-for="(item, iIndex) in report.items" :key="iIndex">
                  <td style="display: none;">{{ item.checkItemId }}</td>
                  <td style="vertical-align: top;" v-html="item.printItemName"></td>
                  <td></td>
                  <td style="text-align: left; vertical-align: top;" v-html="item.printValue == null ? null : item.printValue == 0 ? (cp || wk ? item.nationInspectionItemValue : item.insideInspectionItemValue) : '应符合规定。'"></td>
                  <!-- <td style="text-align: left; vertical-align: top;" v-html="item.printValue == null ? null : item.printValue == 0 ? (cp || wk ? item.nationInspectionItemValue : item.insideInspectionItemValue) : '应符合规定。'"></td> -->
                  <td></td>
                  <td style="vertical-align: top;">
                    <b v-if="item.itemVerdict == 1">
                      <span v-html="item.printConfig == null ? null : item.printConfig == 0 ? parseSixPercent(item) : '不符合规定'"></span>(不符合规定)
                    </b>
                    <span v-else v-html="item.printConfig == null ? null : item.printConfig == 0 ? parseSixPercent(item) : '符合规定'"></span><span v-if="wkShowFhgd(item)">(符合规定)</span>
                  </td>
                </tr>
              </table>
              <div v-if="report.showBlank" class="report-table-blank" :style="{height: blankHeight }">
                <div class="blank-tag">以下为空白</div>
              </div>
            </div>
            <div v-if="!report.showPageDown" class="table-conclusion">
              <div class="t-c-value">
                结论：<span v-if="isVerdict" v-html="cp || wk ? standard.nationVerdict : childDataForm.unfinish ? standard.halfVerdict : standard.insideVerdict"></span>
                <span v-else>
                  <span v-html="cp || wk ? verdictFilter(standard.nationVerdict) : childDataForm.unfinish ? verdictFilter(standard.halfVerdict) : verdictFilter(standard.insideVerdict)"></span>
                  <b>结果不符合规定。</b>
                </span>
                <template v-if="!wk && standard.specialValue != null && standard.specialValue != ''">
                  <br>&nbsp;&nbsp;&nbsp;<span v-html="standard.specialValue"></span>
                </template>
              </div>
            </div>
          </div>
          <div v-if="report.showPageDown" class="text-center">
            (转下一页)
          </div>
          <div v-else id="report-foot" v-show="rfVisible" class="report-foot">
            <div v-if="checkList.checkTypeName == '中间品'">
              <div class="foot-name">报告人：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;复核人：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
              <div class="foot-date">日&nbsp;期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日&nbsp;期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
            </div>
            <div v-else>
              <div class="foot-name">报告人：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              复核人：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              批准人：</div>
              <div class="foot-date">日&nbsp;期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              日&nbsp;期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              日&nbsp;期：</div>
            </div>
          </div>
          <div>
            <div style="margin-left: 750px;font-size: 15px;">页码 Page: {{ rIndex+1 }}/{{ page }}</div>
          </div>
          <div class="full-blank" :style="{height: report.fullToMaxHeight + 'px'}"></div>
        </div>
      </div>
    </div>
	</div>
</template>

<script>
  import { getReportInfo } from '@/api/report'
  import {
    updateListContentForGod,
    updateYfbContentForGod,
    updateZcContentForGod,
    uploadToDingTalk
  } from '@/api/check'
  import { CODE_OK } from '@/common/js/config'
  import { isBlank,parseTime,occurrenceCount,lineToHump,arrEq,unique,getUUID } from '@/common/js/utils'
  import Calc from 'calculatorjs'
  import html2canvas from 'html2canvas'
	export default {
		data() {
			return {
        //修改模式
        isGod: false,
        //修改模式所需data
        productNameInput: false,
        checkNumInput: false,
        productGmpInput: false,
        batchNumInput: false,
        registCheckDepartmentNameInput: false,
        originalBatchInput: false,
        productPackSpecInput: false,
        grossQuantityInput: false,
        supplierNameInput: false,
        manufacturerNameInput: false,
        reinspectDateInput: false,
        validityDateInput: false,
        registCheckDateInput: false,
        inspectDateInput: false,
        reportDateInput: false,
        productionQuantityInput: false,
        productionDateInput: false,
        //底部边距
        bottomBlankHeight: 20,
        //最小时显示空白
        minHeight: 1410,
        //最大时分页,差60
        maxHeight: 1470,
        blankHeight: null,
        updateCssCount: 0,
        page: 1,
        checkList: {
          productName: ''
        },
        yfbList: {},
        zcList: {
          chatId: null
        },
        wkList: {},
        ysList: {},
        standard: {},
        isVerdict: true,
        reportInfo: {
          companyName: '成都倍特',
          reportNum: null,
          reportName: null
        },
        tableList: [
          {
            showBlank: false,
            showPageDown: false,
            showPageUp: false,
            fullToMaxHeight: 0,
            items: []
          }
        ],
        rfVisible: true,
        uploading: false
			}
		},
    props: ["childDataForm"],
    computed: {
      yfb() {
        if (this.childDataForm.checkTypeName == '原料'
        || this.childDataForm.checkTypeName == '辅料'
        || this.childDataForm.checkTypeName == '包材'
        || this.childDataForm.checkTypeName == '其他') {
          return true
        }
        return false
      },
      qt() {
        return this.childDataForm.checkTypeName == '其他'
      },
      zc() {
        if (this.childDataForm.checkTypeName == '中间品'
        || this.childDataForm.checkTypeName == '成品') {
          return true
        }
        return false
      },
      cp() {
        return this.childDataForm.checkTypeName == '成品'
      },
      zp() {
        return this.childDataForm.checkTypeName == '中间品'
      },
      wk() {
        return this.childDataForm.checkTypeName == '稳定性考察'
      },
      ys() {
        return this.childDataForm.checkTypeName == '制药用水/纯蒸汽'
      }
    },
    created() {
      if (!isBlank(this.childDataForm)) {
        let checkTypeId = this.childDataForm.checkTypeId
        this.reportInfo.reportNum = this.reportMap(checkTypeId, 'num')
        this.reportInfo.reportName = this.reportMap(checkTypeId, 'name')
      }
    },
    mounted() {
      this.getData()
      // 如果是成品 硫酸阿米卡星   硫酸卡那霉素   去乙酰毛花苷 ，那么提醒修改产成品量小数点
      if (this.cp) {
        if (this.childDataForm.productGmp == 'H02A' || this.childDataForm.productGmp == 'H01A' || this.childDataForm.productGmp == 'Q01A') {
          this.$alert('请注意修改产成品量的小数点哟', '警告', {
            confirmButtonText: '知道了',
            callback: action => {}
          })
        }
      }
    },
    methods: {
      toSend() {
        if (isBlank(this.zcList.chatId)) {
          return
        }
        this.$confirm('是否将报告书发送到相关钉钉群', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.toDingTalk()
        }).catch(() => {})
      },
      toDingTalk() {
        if (isBlank(this.zcList.chatId)) {
          this.$message.error(this.zcList.workshopName+' 没有配置相关的钉钉群id')
          return
        }
        this.uploading = true
        this.rfVisible = false
        this.$nextTick(()=>{
          html2canvas(document.querySelector("#report-container")).then(canvas => {
            this.rfVisible = true
            // document.querySelector("#report").appendChild(canvas)
            this.uploadToDingTalk(canvas.toDataURL("image/jpeg"))
          })
        })
      },
      uploadToDingTalk(dataUrl) {
        let file = this.dataURLtoFile(dataUrl, getUUID()+'.jpg')
        let fd = new FormData()
        fd.append("file", file)
        fd.append("chatId", this.zcList.chatId)
        uploadToDingTalk(fd).then(res => {
          if (res.code === CODE_OK) {
            this.$message.success("发送至钉钉群成功")
          }else{
            this.$message.error(res.msg)
          }
          this.uploading = false
        })
      },
      dataURLtoFile(dataUrl, fileName) {
        let arr = dataUrl.split(',')
        let mime = arr[0].match(/:(.*?);/)[1]
        let bstr = atob(arr[1])
        let n = bstr.length
        let u8arr = new Uint8Array(n)
        while (n--) {
          u8arr[n] = bstr.charCodeAt(n)
        }
        return new File([u8arr], fileName, {type: mime})
      },
      wkShowFhgd(item) {
        if (this.wk && item.itemVerdict == 0) {
          if (isBlank(item.inspectionItemName)) {
            return false
          }else if(item.inspectionItemName.replace(/ /g,'').indexOf('溶出度') != -1){
            return true
          }else{
            return false
          }
        }else{
          return false
        }
      },
      //修改模式开启，无视规则修改任何信息
      godMode() {
        this.$confirm('开启修改模式将无视任何规则，即可修改任何信息，所见即所得?', '谨慎操作', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$alert('请点击任何你想修改的字符(黄色区域)，修改后立即生效，无法撤销，且只会影响到当前批次请验单以及报告书，若要修改下批次基础资料，有关货品请联系QA管理员(肖慧)，有关标准请联系QC管理员(刘威)')
          this.isGod = true
          this.setCssOn()
        }).catch(() => {
          this.isGod = false
        })
      },
      setCssOn() {
        $(".gold-model").css({
          "background-color" : "gold",
          "cursor" : "pointer"
        })
      },
      setCssOff() {
        $(".gold-model").removeAttr('style')
      },
      godModeExit() {
        this.isGod = false
        this.setCssOff()
      },
      dateTypeFilter(flag) {
        return flag == 1 ? 'month' : 'date'
      },
      dateFormatFilter(flag) {
        return flag == 1 ? 'yyyy年MM月' : 'yyyy年MM月dd日'
      },
      //修改模式修改方法
      setListContent(k, v) {
        const data = {
          value: v,
          checkMergeId: this.childDataForm.checkMergeId,
          key: k
        }
        updateListContentForGod(data).then(res => {
          if (res.code === CODE_OK) {
            this[this.propFilter(k)] = false
            this.$nextTick(() => {
              this.setCssOn()
            })
            this.$message.success('修改成功')
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      setYfbContent(k, v, p) {
        const data = {
          value: v,
          checkMergeId: this.childDataForm.checkMergeId,
          key: k
        }
        updateYfbContentForGod(data).then(res => {
          if (res.code === CODE_OK) {
            if (p != undefined) {
              this[p] = false
            }else{
              this[this.propFilter(k)] = false
            }
            this.$message.success('修改成功')
            this.$nextTick(() => {
              this.setCssOn()
            })
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      setZcContent(k, v, p) {
        const data = {
          value: v,
          checkMergeId: this.childDataForm.checkMergeId,
          key: k
        }
        updateZcContentForGod(data).then(res => {
          if (res.code === CODE_OK) {
            if (p != undefined) {
              this[p] = false
            }else{
              this[this.propFilter(k)] = false
            }
            this.$message.success('修改成功')
            this.$nextTick(() => {
              this.setCssOn()
            })
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      openSet(k, k2) {
        if (this.isGod) {
          this[this.propFilter(k)] = true
          if (k2 != undefined) {
            this[this.propFilter(k2)] = true
          }
        }
      },
      propFilter(k) {
        return lineToHump(k) + 'Input'
      },
      getData() {
        const params = {
          content: this.yfb ? 'yfb' : this.zc ? 'zc' : this.wk ? 'wk' : this.ys ? 'ys' : 'qt',
          checkMergeId: this.childDataForm.checkMergeId,
          unfinish: this.childDataForm.unfinish,
          isParasite: this.childDataForm.isParasite,
          checkId: this.childDataForm.checkId
        }
        getReportInfo(params).then(res => {
          if (res.code === CODE_OK) {
            if (res.info.list != null) {
              this.checkList = res.info.list
            }
            this.yfbList = res.info.yfbList
            if (this.yfbList != null) {
              //如果原辅包的总量单位为kg或g,则过滤位数
              if (this.yfbList.grossUnitName == 'kg' || this.yfbList.grossUnitName == 'g') {
                //如果有小数点并且小数点后只有一位，则加‘0’
                this.yfbList.grossQuantity = this.yfbList.grossQuantity + ''
                if (this.yfbList.grossQuantity.indexOf('.') > -1) {
                  if (this.yfbList.grossQuantity.substring(this.yfbList.grossQuantity.length-2,this.yfbList.grossQuantity.length-1) == '.') {
                    this.yfbList.grossQuantity = this.yfbList.grossQuantity + '0'
                  }
                }else{
                  this.yfbList.grossQuantity = this.yfbList.grossQuantity + '.00'
                }
              }
            }
            this.zcList = res.info.zcList
            if (!isBlank(this.zcList) && this.childDataForm.checkTypeName == '中间品') {
              this.toSend()
            }
            this.wkList = res.info.wkList
            this.ysList = res.info.ysList
            if (this.ys) {
              let gmp = this.checkList.productGmp
              let wCode = this.ysList.workshopCode
              let allRemark = []
              let cgys = res.info.cgys.map(v => {
                this.$set(v,'remarks', [])
                v.cgyqs = v.cgyqs.map(v2 => {
                  let remark = v2.waterQuantityName.replace('检验取样量','')
                  v.remarks.push(remark)
                  if (allRemark.indexOf(remark) == -1) {
                    allRemark.push(remark)
                  }
                  return v2
                })
                return v
              })
              //判断每个点位的remark是否是全部的allRemark，是则不显示，否则显示
              for (let i=0,j=cgys.length; i<j; i++) {
                if (arrEq(allRemark, cgys[i].remarks)) {
                  cgys[i].remarks = null
                }
              }
              this.$set(this.ysList,'getNames','')
              for (let i=0,j=cgys.length; i<j; i++) {
                this.ysList.getNames = this.ysList.getNames + gmp + '-' + wCode + '-' + cgys[i].waterGetName
                if (!isBlank(cgys[i].remarks)) {
                  this.ysList.getNames = this.ysList.getNames + '(' + cgys[i].remarks.join('、') + ')'
                }
                if (i!=j-1) {
                  this.ysList.getNames = this.ysList.getNames + '、'
                }
              }
            }
            this.standard = res.info.standard
            if (this.childDataForm.unfinish) {
              this.isVerdict = this.standard.halfVerdict.indexOf("不符合规定")  == -1
            }else{
              this.isVerdict = this.standard.verdict == 0
            }
            this.tableList[0].items = res.info.items
            if (!isBlank(res.info.specialItems)) {
              this.tableList[0].items = this.itemsPushSpecial(this.tableList[0].items, res.info.specialItems)
            }
            if (this.childDataForm.unfinish) {
              this.checkList = this.childDataForm
              this.checkList.checkNum = new Date(this.checkList.registCheckDate).getFullYear() + "-" + this.checkList.productGmp + "-" + this.checkList.batchNum
              if (this.checkList.inspectDate == null) {
                let minInspectDate = new Date()
                let items = this.tableList[0].items
                for (let item of items) {
                  let tempDate = new Date(item.startTime)
                  if (tempDate.getTime() < minInspectDate.getTime() && item.checkItemId != null) {
                    minInspectDate = tempDate
                  }
                }
                this.checkList.inspectDate = parseTime(minInspectDate)
              }
            }
            this.$nextTick(() => {
              this.paint(0)
            })
          }else{
            this.$message.error(res.msg)
            this.close()
          }
        })
      },
      itemsPushSpecial(olds, news) {
        let arr = []
        // 分类数组
        let cs = unique(news.map(i => {return i.specialItemCategory}))
        for(let i=0,j=cs.length; i<j; i++) {
          let ni = {
            printItemName: cs[i],
            isPrint: 0,
            printValue: null,
            printConfig: null
          }
          arr.push(ni)
          // 找出属于这个分类的
          for (let x=0,y=news.length; x<y; x++) {
            if (!isBlank(news[x]) && news[x].specialItemCategory == cs[i]) {
              arr.push({
                isPrint: 0,
                printItemName: news[x].specialItemName,
                printValue: 0,
                nationInspectionItemValue: news[x].specialItemValue,
                insideInspectionItemValue: news[x].specialItemValue,
                printConfig: 0,
                itemConclusionMerge: news[x].specialItemConclusion
              })
              news[x] = null
            }
          }
        }
        olds.push(...arr)
        return olds
      },
      paint(index) {
        let reportId = this.reportId(index)
        let currentHeight = this.getHeightById(reportId)
        if (currentHeight < this.minHeight) {
          //底部留20px边距
          this.tableList[index].fullToMaxHeight = JSON.parse(JSON.stringify(this.bottomBlankHeight))
          this.blankHeight = this.maxHeight - currentHeight - this.bottomBlankHeight
          this.blankHeight = this.blankHeight + 'px'
          this.tableList[index].showBlank = true
        }else if(currentHeight > this.maxHeight) {
          //控制成品不得超过1页
          if (this.checkList.checkTypeName == '成品') {
            //第一次修改td > height: 40px->30px
            if (this.updateCssCount == 0) {
              $(".jyxm").css({"height" : '30px'})
            }
            //第二次以后修改report-container > line-height: px - 1
            if (this.updateCssCount > 0) {
              let nowPxNum = $(".report-container").css("line-height").replace('px','') * 1
              let nextPxNum = Calc.sub(nowPxNum,1)
              $(".report-container").css({"line-height" : nextPxNum+'px'})
            }
            this.updateCssCount++
            this.$nextTick(() => {
              this.paint(0)
            })
            return
          }
          let table = document.getElementById(this.tableId(index))
          while(this.getHeightById(reportId) > this.maxHeight){
            table.removeChild(table.lastChild)
          }
          this.tableList[index].showPageDown = true
          this.$nextTick(() => {
            this.fullToMax(index)
            let lastId = parseInt(table.lastChild.firstChild.innerHTML)
            let data = this.tableList[index]
            let sIndex = null
            for (let i=0,j=data.items.length; i<j; i++) {
              if (lastId == data.items[i].checkItemId) {
                sIndex = i + 1
                break
              }
            }
            let standardNewArr = data.items.splice(sIndex)
            let newData = {
              showBlank: false,
              showPageDown: false,
              showPageUp: true,
              fullToMaxHeight: 0,
              items: standardNewArr
            }
            this.tableList.push(newData)
            this.page = this.page + 1
            this.$nextTick(() => {
              this.paint(index + 1)
            })
          })
        }
      },
      verdictFilter(text) {
        return text.substring(0,text.indexOf("结果不符合规定"))
      },
      fullToMax(index) {
        let reportId = this.reportId(index)
        if (this.getHeightById(reportId) < this.maxHeight){
          this.tableList[index].fullToMaxHeight = this.maxHeight - this.getHeightById(reportId)
        }
      },
      reportId(index) {
        return 'one-report_' + index
      },
      tableId(index) {
        return 'report-table_' + index
      },
      blankId(index) {
        return 'blank_' + index
      },
      getHeightById(id) {
        return parseInt(window.getComputedStyle(document.getElementById(id)).getPropertyValue('height'))
      },
      close() {
        this.$emit('close')
      },
      reportMap(checkTypeId, prop) {
        const map = {
          1: {
            num: "ZK / SMP·032-R02-02",
            name: "原料检验报告"
          },
          2: {
            num: "ZK / SMP·032-R03-02",
            name: "辅料检验报告"
          },
          3: {
            num: "ZK / SMP·032-R04-02",
            name: "包材检验报告"
          },
          4: {
            num: "ZK / SMP·032-R05-05",
            name: "中间产品检验结果通知单"
          },
          5: {
            num: null,
            name: "成品检验报告"
          },
          6: {
            num: "ZK / SMP·032-R09-02",
            name: "检验报告"
          },
          7: {
            num: "ZK / SMP·032-R07-02",
            name: "制药用水检验报告"
          },
          9: {
            num: "ZK / SMP·032-R09-02",
            name: "检验报告"
          }
        }
        return map[checkTypeId][prop]
      },
      parseSixPercent(item) {
        if (isBlank(item)) {
          return ''
        }
        let value = item.itemConclusionMerge
        if (isBlank(value)) {
          return ''
        }
        //微生物限度，或者数值，0+单位
        if (!isBlank(item.inspectionItemName)) {
          if (item.inspectionItemName.replace(/ /g,'') == '微生物限度' && item.isNumber == 0 && value.replace(/ /g,'') == ('0' + item.insideInspectionItemValueUnit)) {
            return '<1 ' + item.insideInspectionItemValueUnit
          }
          if (item.isNumber == 0 && item.itemConclusionMerge.replace(item.insideInspectionItemValueUnit, '') == '0') {
            return '未检出'
          }
        }
        let count = occurrenceCount(value, '%')
        if (count == 6 || count == 12) {
          let sixConcArr = value.split(';')
          value = ''
          for (let i=0,j=sixConcArr.length; i<j; i++) {
            let conc = sixConcArr[i]
            let ii = i + 1
            if (ii % 2 == 0) {
              value = value + conc + '<br>'
            }else{
              if (i==j-1){
                value = value + conc
              }else{
                value = value + conc + '、'
              }
            }
          }
        }else if(count == 1){
          if (value == '0%' || value == '0.0%' || value == '0.00%') return '未检出'
        }
        //手动换行
        var str = '';
        if(value.length > 80){
           for(let i=0;i<value.length;i++){
               str+=value[i]
               if(i>0&&i%15==0){
                   str+='</br>'
               }
           }
           return  str
        }
        return value
      },
      number2Filter(prop1, prop2, prop3) {
        if (this.isGod) {
          this.openSet(prop3)
          return
        }
        let number = this[prop1][prop2]
        if (isBlank(number)) return
        number = number + ''
        //如果不带小数点，则加上 '.0'
        if (number.indexOf('.') == -1) {
          number = number + '.0'
        }else{
          //如果带小数点,则加0,不允许超过4位
          number = number + '0'
          //如果最后5位为'00000'，则重置
          if (number.substring(number.length - 5) == '00000') {
            number = number.substring(0,number.length - 5)
            if (number.substring(number.length - 1) == '.') {
              number = number.substring(0,number.length - 1)
            }
          }
        }
        this[prop1][prop2] = number
      }
    }
	}
</script>

<style type="text/scss" lang="scss" scoped>
  .report-container{
    color: black;
    font-family: SimSun;
    font-size: 18px;
    width: 939px;
    padding: 15px;
    line-height: 1.42857143;
    .report-head{
      height: 55px;
      padding: 0 15px;
      .report-head-box{
        height: 45px;
        .report-head-logo{
          width: 37px;
          height: 100%;
          float: left;
        }
        .report-head-logo img{
          vertical-align: inherit;
          height: 100%;
          width: 100%;
        }
        .report-head-text{
          margin-left: 20px;
          float: left;
          margin-top: 15px;
        }
      }
      .report-head-line{
        border-top: solid 3px #bfbfbf;
        border-bottom: solid 3px black;
        height: 10px;
      }
    }
    .name-box{
      height: 100px;
      .report-name{
        text-align: center;
        font-size: 30px;
        line-height: 100px;
      }
    }
    .table-box{
      width: 100%;
      border: solid 1px;
      border-bottom:solid 2px;
      .page-up{
        border: solid 1px;
        border-top: none;
      }
      .report-table-container{
        border-left: solid 1px;
        border-right: solid 1px;
        .report-table-blank{
          padding: 5px 405px;
          .blank-tag{
            border: solid black 1px;
          }
        }
      }
      .info-lable{
      	width: 150px;
        height: 34px;
        text-align: center;
      }
      .info-value-container{
      	width: 305px;
        .info-value{
        	margin-left: 5px;
        }
      }
      .table-conclusion{
        border: solid 1px;
        border-bottom: none;
        line-height: 30px;
        .t-c-value{
          margin-left: 5px;
        }
      }
    }
    .report-foot{
      margin-top: 20px;
      margin-bottom: 10px;
      width: 100%;
      height: 70px;
      .foot-name{
        height: 35px;
        padding: 0 70px;
      }
      .foot-date{
        margin-top: 10px;
        height: 35px;
        padding: 0 70px;
      }
    }
    .full-blank{
      width: 100%;
    }
  }
  .jyxm{
    padding-left: 4px;
    width: 170px;
    height: 40px;
  }
  .jyxm_b{
    width: 30px;
  }
  .bzgd{
    width: 525px;
    text-align: center;
  }
  .bzgd_b{
    width: 30px;
  }
  .jyjg{
    margin-left: 2px;
    width: 155px;
  }
  .jyjg_b{
    width: 10px;
  }
</style>
